//
//  NewsInfo.m
//  TodayComment
//
//  Created by 张吉阳 on 15/9/12.
//  Copyright (c) 2015年 xianrenmoshi. All rights reserved.
//

#import "NewsInfo.h"

@implementation NewsInfo
+ (NewsInfo *)infoFromDict:(NSDictionary *)dict
{
    NewsInfo *info = [[NewsInfo alloc] init];
    info.ID = [dict valueForKey:@"docid"];
    info.iconUrl = [dict valueForKey:@"imgsrc"];
    info.name = [dict valueForKey:@"boardid"];
    info.contentUrl = [dict valueForKey:@"url"];
    info.replyCount = [[dict valueForKey:@"replyCount"] intValue];
    return info;
}

+ (NSArray *)arrayFromDict:(NSDictionary *)dict
{
    NSArray *keys=[dict allKeys];
    NSArray *array = [dict valueForKey:keys[0]];
    return [[self class] arrayFromArray:array];
}

+ (NSArray *)arrayFromArray:(NSArray *)array
{
    NSMutableArray *infos = [[NSMutableArray alloc] init];
    
    for (NSDictionary * dict in array) {
        if ([[dict valueForKey:@"boardid"] length] <= 0) {
            continue;
        }
        if ([[dict valueForKey:@"replyCount"] intValue] >= 23) {
            [infos addObject:[[self class] infoFromDict:dict]];
        }
    }
    
    if (infos.count <= 0) {
        infos = nil;
    }
    
    return infos;
}


@end
